<template>
	<view class="box">
		<uni-nav-bar backgroundColor="#e7e7e7" color=#333 :left-icon="leftIcon" :leftText="leftText"
			:rightText="rightText" :title="title" :border="false" :right-icon="rightIcon" @clickLeft="clickLeft"
			@clickRight="clickRight" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				statusBarHeight: 0
			}
		},
		mounted() {
			this.getSystemInfoSync()
		},
		methods: {
			getSystemInfoSync() {
				const systemInfo = uni.getSystemInfoSync(); // 获取系统信息
				this.statusBarHeight = `${systemInfo.statusBarHeight?systemInfo.statusBarHeight:40}px`
				// console.log('状态栏高度:', systemInfo);
			},
			clickLeft() {
				uni.navigateBack({
					delta: 1
				})
				this.$emit('clickLeft');
			},
			clickRight() {
				this.$emit('clickRight');
			}

		},
		props: {
			leftText: {
				type: String,
				default: ''
			},
			title: {
				type: String,
				default: '默认标题'
			},
			rightText: {
				type: String,
				default: ''
			},
			rightIcon: {
				type: String,
				default: ''
			},

			leftIcon: {
				type: String,
				default: ''
			}
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		// background-color: #e7e7e7;
		// position: fixed;
		width: 100vw;
		// top: 0;
		// left: 0;
		// right: 0;
		// z-index: 1;
		// padding: 0 10px;
	}

	.nav_box {
		margin: auto;
		width: calc(100% - 20px);
		display: flex;
		align-items: center;
		justify-content: space-between;
		// text-align: center;
	}
</style>